Skip to content

DATACMNS-1190 - Added section on how to enforce nullability constraints on repositories #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

odrotbohm
Copy link
Member

No description provided.

@odrotbohm odrotbohm force-pushed the issue/DATACMNS-1190 branch from 5a449ba to 1f12660 Compare October 6, 2017 08:44
Copy link
Member

@mp911de mp911de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change duplicates already existing documentation. Merging what we have with this change and leaving it below Defining repository interfaces seems a good fit.

The absence of a query result will then be indicated by returning `null`.
Repository methods returning collection like values will never return null but an empty value.

[[repositories.nullability.annotations]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section duplicates the section on Null-safety that is currently in place. It would make sense to move core.nullability-validation in here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After revisiting the other version of the docs, I'd actually like to keep this one here and augment it with the following aspects currently present in the other version:

  • Nullability annotations should list the fully-qualified name at least once, so that it's clear what to import. I think we can (should?) leave out the remark with JSR-305 needed for meta-annotation usage. That's taking it a bit too far I think.
  • The kotlin-reflect library needed to get the runtime checks enabled.


Alternatively query methods can choose not to use a wrapper type at all.
The absence of a query result will then be indicated by returning `null`.
Repository methods returning collection like values will never return null but an empty value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about Repository methods returning collections, wrappers, and streams are guaranteed to never return null but rather the corresponding empty representation.?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should link to the appendix table listing all supported return types as they also list the alternative collection types we support that might be handy to know about but don't need any discussion here.

==== Nullability in Kotlin-based repositories

Kotlin has the definition of nullability constraints baked into the language.
Spring Data repositories using the language mechanism to define those constraints will automatically get the same runtime checks applied:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a good place to mention the need to have kotlin-reflect on the classpath.

Remove existing section on Null-safety. Augment Null handling section with bits of the previous documentation, explicitly describe annotations expressing null-constraints, include full-qualified imports, mention kotlin-reflect dependency for Kotlin metadata introspection. Align callouts, add links, slightly improve wording, typos. Extend year range in copyright header.
@mp911de mp911de force-pushed the issue/DATACMNS-1190 branch from d7bfa82 to fe4a09d Compare October 11, 2017 09:18
odrotbohm added a commit that referenced this pull request Oct 11, 2017
odrotbohm pushed a commit that referenced this pull request Oct 11, 2017
Remove existing section on Null-safety. Augment Null handling section with bits of the previous documentation, explicitly describe annotations expressing null-constraints, include full-qualified imports, mention kotlin-reflect dependency for Kotlin metadata introspection. Align callouts, add links, slightly improve wording, typos. Extend year range in copyright header.

Original pull request: #253.
odrotbohm added a commit that referenced this pull request Oct 11, 2017
Slight rewording. Extracted path to Spring Framework JavaDoc into variable.

Original pull request: #253.
@odrotbohm odrotbohm closed this Oct 11, 2017
@odrotbohm odrotbohm deleted the issue/DATACMNS-1190 branch October 11, 2017 13:39
odrotbohm added a commit that referenced this pull request Oct 11, 2017
Slight rewording. Extracted path to Spring Framework JavaDoc into variable.

Original pull request: #253.
odrotbohm added a commit that referenced this pull request Oct 11, 2017
Slight rewording. Extracted path to Spring Framework JavaDoc into variable.

Original pull request: #253.
odrotbohm added a commit that referenced this pull request Oct 11, 2017
odrotbohm pushed a commit that referenced this pull request Oct 11, 2017
Remove existing section on Null-safety. Augment Null handling section with bits of the previous documentation, explicitly describe annotations expressing null-constraints, include full-qualified imports, mention kotlin-reflect dependency for Kotlin metadata introspection. Align callouts, add links, slightly improve wording, typos. Extend year range in copyright header.

Original pull request: #253.
odrotbohm added a commit that referenced this pull request Oct 11, 2017
Slight rewording. Extracted path to Spring Framework JavaDoc into variable.

Original pull request: #253.
Aloren pushed a commit to Aloren/spring-data-commons that referenced this pull request Jun 20, 2019
Aloren pushed a commit to Aloren/spring-data-commons that referenced this pull request Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants